package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WarnUserLog;
import com.ruoyi.system.domain.dto.InterviewLogDTO;
import com.ruoyi.system.domain.vo.InterviewLogVO;
import com.ruoyi.system.domain.vo.SysUserVO;
import com.ruoyi.system.mapper.WarnUserLogMapper;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.InterviewLogMapper;
import com.ruoyi.system.domain.InterviewLog;
import com.ruoyi.system.service.IInterviewLogService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-14
 */
@Service
public class InterviewLogServiceImpl implements IInterviewLogService {
    @Autowired
    private InterviewLogMapper interviewLogMapper;

    @Autowired
    private WarnUserLogMapper warnUserLogMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public InterviewLog selectInterviewLogById(Long id) {
        return interviewLogMapper.selectInterviewLogById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param interviewLog 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<InterviewLogVO> selectInterviewLogList(InterviewLogDTO interviewLog) {
        return interviewLogMapper.selectInterviewLogList(interviewLog);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param interviewLog 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertInterviewLog(InterviewLog interviewLog) {
        interviewLog.setCreateTime(DateUtils.getNowDate());
        return interviewLogMapper.insertInterviewLog(interviewLog);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param interviewLog 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateInterviewLog(InterviewLog interviewLog) {
        interviewLogMapper.updateInterviewLog(interviewLog);
        WarnUserLog warnUserLog = warnUserLogMapper.selectWarnUserLogById(interviewLog.getWarnId());
        warnUserLog.setIsInterview(1); //已访谈
        warnUserLog.setLevelJudge(2); //第二阶段
        //更新预警
        warnUserLogMapper.updateWarnUserLog(warnUserLog);
        return 1;
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInterviewLogByIds(Long[] ids) {
        return interviewLogMapper.deleteInterviewLogByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteInterviewLogById(Long id) {
        return interviewLogMapper.deleteInterviewLogById(id);
    }
}
